package com.lovo.es.service;

import com.lovo.es.Entity.NewEntity;
import com.lovo.es.Entity.NewEntityDto;
import com.lovo.es.dao.INewsDao;
import com.lovo.es.dao.INewshibernate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;

@Component
public class NewsService {
   @Autowired
   INewshibernate iNewshibernate;

   @Autowired
   INewsDao iNewsDao;
   @Transactional
   public void addNews(NewEntity entity) {

      iNewsDao.save(entity);

      NewEntityDto newEntityDto=new NewEntityDto();
      newEntityDto.setTitle(entity.getTitle());
      newEntityDto.setNewsEsId(entity.getNewsId());
      newEntityDto.setCreatDate(entity.getCreatDate());

    iNewshibernate.save(newEntityDto)  ;


   }

}
